<template>
	<view class="bodys">
		<div class="money">
			<input type="number" placeholder="请输入金额" class="moneys" v-model="num">
		</div>
		<div class="baocun ">
			<div class="tongyi">
				<div>
					<u-checkbox-group class="checkeds">
						<u-checkbox v-model="checked" shape="shape"></u-checkbox>
					</u-checkbox-group>
				</div>
				<div>
					阅读并同意用户协议<span style="color: red;">《用户充值协议》</span>
				</div>
			</div>
			<div class="buttons">
				<button type="primary"  @click="chongzhi()">保存</button>
			</div>
		</div>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				value: "",
				border: true,
				checked: false,
				num: "100",
				agent_id:'',
				id:'',
				request:true
			}
		},
		
		methods: {
			radioChange() {
				console.log("内容改变了")
			},
				chongzhi() {
				this.agent_id= wx.getStorageSync('customer_id')
				let agent_id = this.agent_id
				console.log(agent_id)
				if(this.checked){
					this.$flyio.post('v1.Customer/recharge', {
									amount:this.num,
									customer_id:this.agent_id,
								}).then((ret) => {
									console.log(ret)								
										this.id = ret.data.project_id
											uni.navigateTo({
											  url:"/pages/zhifu/zhifuxiangqing?project_id="+this.id
											})
											
								})
								.catch((e) => {
								
								})
					
				}
				else{
					uni.showModal({
							title: '友情提示',
							content: '请先勾选用户协议',
							success: function(res) {
								if (res.confirm) {
									console.log('用户点击确定');
								} else if (res.cancel) {
									console.log('用户点击取消');
								}
							}
						})
					
				}
		},
		}
	}
</script>

<style scoped lang="scss">
	.tongyi {
		height: 25upx;
		width: 100%;
		display: flex;
		flex-direction: row;
		// background-color: green;
		// border: 1px solid red;

	}

	.money {
		.moneys {
			box-sizing: border-box;
			padding-left: 100upx;
			width: 100%;
			height: 100%;
			// border: 1px solid red;
			text-indent: 90px;
		}

		border: 1px solid $gary;
		text-indent: 90upx;
		height: 85rpx;
		width: 661rpx;
		margin: 0 auto;
		// background-image: url("http://pdd.xuhuinet.com/upload/icons/qianhongse.png");
		background-repeat: no-repeat;
		background-size: 20upx 28upx;
		background-position: 42upx 50%;
	}

	.bodys {
		// box-sizing: border-box;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		padding-top: 46upx;
		height: 100%;
		border: 1px solid green;
		// background-color: green;
		// height: 1250upx;
	}

	.baocun {
		margin: 0 auto;
		bottom: 42rpx;
		font-size: 24rpx;
		height: 203upx;
		width: 661rpx;

		// border: 1px solid red;
		.buttons {
			margin-top: 47upx;
		}
	}
</style>
